fix(config): fall back to defaults on malformed numeric config values#488
Conversation
recall.load_config and capture.load_config both document "read the namespace; fall back to defaults" but only guarded the read of config.yaml itself, not the int()/float() coercion of individual values. a typo like `max_chars: a lot` raised an uncaught ValueError straight out of the SessionStart recall hook; the same shape of typo in capture: crashed observe()/finalize(). compile.load_config already solved this with a small _coerce(value, default, cast) helper (see the comment at compile.py:64-70) and has a test proving it. mirror that pattern in recall.py and capture.py so all three load_config functions honor the same fallback contract, and add the matching regression tests. validated: pytest tests/ -q --ignore=tests/embeddings, mypy src, ruff check src tests all pass.
|
Warning Review limit reached
Next review available in: 57 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
what changed:
recall.load_configandcapture.load_confignow route their numeric config values (max_chars,min_observations,dedup_window_seconds) through a small_coerce(value, default, cast)helper instead of a bareint()/float()call, so a malformed value falls back to the default instead of raising.why: both docstrings already promise "read the
<namespace>:stanza; fall back to defaults," andcompile.load_configalready implements exactly that contract with a_coercehelper (seecompile.py:64-70, added for the same reason — a config typo must degrade, not take down every caller).recall.pyandcapture.pyonly guarded the yaml read/parse, not the per-field coercion, so a config typo likemax_chars: a lotraised an uncaughtValueErrorstraight out of the SessionStart recall hook, and the equivalent typo undercapture:crashed any hook-drivenobserve()/finalize()call. this mirrors the existing, tested pattern rather than introducing a new one.nothing on disk changes shape — no migration impact, no effect on an existing
.vouch/directory. behavior only changes for the malformed-value case, which previously crashed.validation commands run:
.venv/bin/python -m pytest tests/ -q --ignore=tests/embeddings(full suite, all green).venv/bin/python -m mypy src(clean).venv/bin/python -m ruff check src tests(clean)ValueErroron the pre-fix code (stashed the src changes, reran) and pass with the fix restored